from selenium import webdriver
import time
import requests
import threading
from concurrent.futures import ThreadPoolExecutor


class Test01:
    def __init__(self):
        print("--init--")

    def myRun(self):
        driver = webdriver.Chrome()
        url = "http://localhost:9001/index"
        driver.get(url)
        div = driver.find_elements_by_tag_name("a")
        for i in range(0, len(div)):
            div[i].click()
            driver.back()
            div = driver.find_elements_by_tag_name("a")
        # element = driver.find_element_by_xpath("//input[@id='kw']")
        # button = driver.find_element_by_css_selector('#su')
        # while i < 5:
        #     element.send_keys("seleniun自动化测试:%d", i)
        #     button.click()
        #     time.sleep(5)
        #     print("--正在加载中--")
        # print(driver.page_source)
        # driver.close()


if __name__ == "main":
    print("--main--")
# def func():
#         i = 0;
#         while i < 1000:
#             response = requests.post("https://test.ironz.com/api/advise")
#             print(response.text)
#             i += 1
#             print(threading.current_thread().name+"成功打印了 %d" % (i))
t1 = Test01()
t1.myRun()


def action(max):
    my_sum = 0
    for i in range(max):
        print(threading.current_thread().name + '  ' + str(i))
        my_sum += i
    return my_sum
# executor = ThreadPoolExecutor(max_workers=10)
# task1 = executor.submit(func)
# task2 = executor.submit(func)
# task3 = executor.submit(func)
# task4 = executor.submit(func)
# task5 = executor.submit(func)
# task6 = executor.submit(func)
# task7 = executor.submit(func)
# task8 = executor.submit(func)
# task9 = executor.submit(func)
# task10 = executor.submit(func)
# print(task1.done())
# print(task2.done())
# 定义一个准备作为线程任务的函数
